//
//  CellForCBA.m
//  MY Project For Sport
//
//  Created by dllo on 16/2/1.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForCBA.h"
#import "ModelForCBA.h"
#import <DKNightVersion.h>


#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667


@interface CellForCBA ()

@property (nonatomic, retain) UILabel *labelForName;
@property (nonatomic, retain) UILabel *labelForOrder;
@property (nonatomic, retain) UILabel *labelForWin;
@property (nonatomic, retain) UILabel *labelForLose;
@property (nonatomic, retain) UILabel *labelForAverage;
@property (nonatomic, retain) UILabel *labelForShenglv;

@end


@implementation CellForCBA

- (void)dealloc {
    [_labelForAverage release];
    [_labelForLose release];
    [_labelForName release];
    [_labelForShenglv release];
    [_labelForWin release];
    [_labelForOrder release];
    [super dealloc];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style  reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.contentView.dk_backgroundColorPicker = DKColorWithRGB(0xffffff, 0x343434);
        

        [self createSubview];
        
    }

    return self;
}

- (void)createSubview {

    self.labelForAverage = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForAverage];
    [_labelForAverage release];
   self.labelForAverage.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

    
    self.labelForLose = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForLose];
    [_labelForLose release];
    self.labelForLose.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

    
    self.labelForName = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForName];
    [_labelForName release];
    self.labelForName.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

    
    self.labelForShenglv  = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForShenglv];
    [_labelForShenglv release];
    self.labelForShenglv.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

    
    self.labelForWin = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForWin];
    [_labelForWin release];
    self.labelForWin.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

    
    self.labelForOrder = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForOrder];
    [_labelForOrder release];
    self.labelForOrder.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    

    
 }


- (void)layoutSubviews {

    [super layoutSubviews];
    
    self.labelForOrder.frame = CGRectMake(10 * WEIGHTT, WIDTH / 28, WIDTH / 15, WIDTH / 15);
    self.labelForOrder.layer.cornerRadius = WIDTH / 30;
    self.labelForOrder.layer.masksToBounds = YES;
    // self.labelForOrder.backgroundColor = [UIColor redColor];
    
    self.labelForName.frame = CGRectMake(WIDTH / 15 + 20 * WEIGHTT, WIDTH / 28, WIDTH / 4, WIDTH / 15);
   //  self.labelForName.backgroundColor = [UIColor grayColor];

    self.labelForWin.frame = CGRectMake(30 * WEIGHTT + WIDTH / 15 + WIDTH / 4 + WIDTH / 13, WIDTH / 28, WIDTH / 13, WIDTH / 15);
    //self.labelForWin.backgroundColor = [UIColor greenColor];

    self.labelForLose.frame = CGRectMake(30 * WEIGHTT + WIDTH / 15 + WIDTH / 4 + WIDTH / 13 + WIDTH / 16 * 2, WIDTH / 28 , WIDTH / 13, WIDTH / 15);
     //self.labelForLose.backgroundColor = [UIColor yellowColor];

    self.labelForShenglv.frame = CGRectMake(30  * WEIGHTT + WIDTH / 15 + WIDTH / 4 + WIDTH / 13 * 4, WIDTH / 28, WIDTH / 9, WIDTH / 15);
    //self.labelForShenglv.backgroundColor = [UIColor blueColor];

    self.labelForAverage.frame = CGRectMake(30 * WEIGHTT + WIDTH / 20 + WIDTH / 15 + WIDTH / 4 + WIDTH / 13 * 5, WIDTH / 28, WIDTH / 6, WIDTH / 15);
    // self.labelForAverage.backgroundColor = [UIColor purpleColor];

}

- (void)passModelForData:(ModelForCBA *)model {

    self.labelForName.text = model.name;
    self.labelForOrder.text =[NSString stringWithFormat:@"%ld", model.order];
    self.labelForLose.text = model.lose;
    self.labelForWin.text = model.win;
    self.labelForAverage.text = model.score_average;
    self.labelForShenglv.text = model.shenglv;

}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
